<?php
/**
 * Smarty plugin
 * @package Smarty
 * @subpackage plugins
 */


/**
 * Smarty {html_options} function plugin
 *
 * Type:     function<br />
 * Name:     html_options<br />
 * Input:<br />
 *           - name       (optional) - string default "select"
 *           - values     (required if no options supplied) - array
 *           - options    (required if no values supplied) - associative array
 *           - selected   (optional) - string default not set
 *           - output     (required if not options supplied) - array
 * Purpose:  Prints the list of <option> tags generated from
 *           the passed parameters
 * @link http://smarty.php.net/manual/en/language.function.html.options.php {html_image}
 *      (Smarty online manual)
 * @param array
 * @param Smarty
 * @return string
 * @uses smarty_function_escape_special_chars()
 */
function smarty_function_html_binary($params, &$smarty) {
	
	$name		= 'binary';
	$checked	= 1;
	
	if(isset($params['name'])) {
		
		$name		= $params['name'];
		
	}
	
	if(isset($params['checked'])) {
		
		$checked	= (int)$params['checked'];
		
	}
	
	if($checked === 1) {
		
		$yes_checked	= 'checked';
		
	} else {
	
		$no_checked		= 'checked';
	
	}

	return '<label>Yes <input type="radio" name="'. $name .'" value="1" '. $yes_checked .'></label> <label><input type="radio" name="'. $name .'" value="0" '. $no_checked .'> No</label>';
	
}

?>
